Sqoop Eval

This chapter describes how to run simple SQL queries agaist database server. The ‘eval’ commands is use to access the database and tables form  the Hadoop Environment. Also to preview the result in the console, we use Sqoop Eval tool
Syntax
Sqoop eval \
--connect <JDBC connection strings> \
--username<usrename> --password <password>\
--table <tablename>
--target-dir<hdfs-dir>
  •  The argument –connect specifies the JDBC connect string.
  •  The arguments –username and –password specify the authentication data.
  •  The argument –table specifies the table to read.
  • Alternatively you can use –query, which means to import data from an arbitrary SQL query.
  •  The argument –target-dir specifies the destination in HDFS. Optionally you can specify the number map tasks by adding -m 1.
Syntax
Syntax:-  sqoop eval (generic-args) (eval-args)

Sqoop eval
To quickly run simple SQL queries against a database, we use Sqoop Eval tool in Sqoop.It allows users to execute user-defined queries against respective database servers and preview the result in the console. So, the user can expect the resultant table data to import. Using eval, we can evaluate any type of SQL query that can be either DDL or DML statement. It allows user to execute user-defined queries against respective database servers and preview the result in the console.
  • Evaluate any type of SQL DDL query that can either DDL.
  • Evaluate any type of SQL DML statement.
Arguments
We can specify the sql statement with  --e statement>  or -–query <statement. Example
  • --query "select * from emp limit 3";
  • --e "select * from emp limit 3";
  • --e "insert into emp values (130,'EMP130',130000,'00A5')";
eval example
sqoop eval --connect jdbc:mysql://localhost:3306/dwdev --username root --password cloudera --query "select * from emp limit 3";
sqoop eval --connect jdbc:mysql://localhost:3306/dwdev --username root --password cloudera --query "select * from emp where esal > 15000";
sqoop eval --connect jdbc:mysql://localhost:3306/dwdev --username root --password cloudera --e "select * from emp where esal > 15000";
sqoop eval --connect jdbc:mysql://localhost:3306/dwdev --username root --password cloudera --e "insert into emp values (130,'EMP130',130000,'00A5')";
sqoop eval --connect jdbc:mysql://localhost:3306/dwdev --username root --password cloudera --query "select * from emp";
sqoop eval --connect jdbc:mysql://localhost:3306/reatil_db --username cloudera --password cloudera --query "select * from products";

No comments:

Post a Comment